﻿import request from '/@/utils/request';
enum Api {
  AddProjectResult = '/api/projectResult/add',
  DeleteProjectResult = '/api/projectResult/delete',
  BatchDeleteProjectResult = '/api/projectResult/batchDelete',
  UpdateProjectResult = '/api/projectResult/update',
  ImportProjectResult = '/api/projectResult/import',
  DownLoadProjectResult = '/api/ProjectResult/DownLoad',
  PageProjectResult = '/api/projectResult/page',
  GetProResultDetail='/api/projectResult/getProResultDetail',
  GenerateWarehouseMap='/api/projectResult/generate',
  EditWarehouseMap='/api/projectResult/editProjectMapDetailAsync',
  GenerateScheme='/api/Project/GeneratePpt',
  seleProjectMapDetail='/api/Project/seleProjectMapDetail',
  CalculateMap='/api/projectResult/calculate',
  GenerateTModel = '/api/projectResult/uploadGRIDiles',
  UploadCADFiles = '/api/project/uploadCADFiles',
    addCADFiles = '/api/project/addCADFiles',
	updaagv = '/api/Project/updaagv'

}
export const getProResultDetail = (params?: any) =>
	request({
			url: Api.GetProResultDetail,
			method: 'post',
			data: params,
		});
// 生成仓库地图
export const generateWarehouseMap = (params?: any) =>
	request({
		url: Api.GenerateWarehouseMap,
		method: 'post',
		data: params
	});
// 生成方案
export const generateScheme = (projectId: any,projectMapDetailId:any) =>
	request({
		url: `${Api.GenerateScheme}/${projectId}/${projectMapDetailId}`,
		method: 'get',
		responseType: 'blob'
	});

//修改小黄人
export const updaagv = (projectMapDetailId: any,agv:any) =>
	request({
		url: `${Api.updaagv}/${projectMapDetailId}/${agv}`,
		method: 'get',
		responseType: 'blob'
	});

// 修改仓库地图
export const editProjectMapDetailAsync = (params?: any) =>
	request({
		url: Api.EditWarehouseMap,
		method: 'post',
		data: params
	});
//计算统计数据
export const calculateMap = () =>
	request({
		url: Api.CalculateMap,
		method: 'get'
	});
//上传
export const generateTModel = (file: File, projectId: string) => {
	const formData = new FormData();
	formData.append('file', file); // 只添加 file

	const url = `${Api.GenerateTModel}/${projectId}`; // 拼接 URL

	return request({
		url: url,
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data',
		},
	});
};
// 上传 CAD 文件
export const uploadCADFiles = (file: File) => {
	const formData = new FormData();
	formData.append('file', file); // 添加文件到 formData

	return request({
		url: Api.UploadCADFiles, // 使用定义的 API URL
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data' // 设置请求头
		}
	});
};




// 转为 CAD 文件
export const addCADFiles = (file: File,projectMapDetailId:any) => {
	const formData = new FormData();
	formData.append('file', file); // 只添加 file

	const url = `${Api.addCADFiles}/${projectMapDetailId}`; // 拼接 URL

	return request({
		url: url,
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data' // 设置请求头
		}

	});
};


// 查询ProjectMapDetail
export const seleProjectMapDetail = (projectId: any,projectMapDetailId:any) => {
	 return request({
		url: `${Api.seleProjectMapDetail}/${projectId}/${projectMapDetailId}`,
		method: 'get',
		responseType: 'blob'
	});
};















// 导入
export const importProjectResult = (params?: any) => {
	const formData = new FormData();
	formData.append('file', params);
	// 请求配置
	const config = {
		headers: {
		},
	};
	request({
		url: Api.ImportProjectResult,
		method: 'post',
		headers:{'Content-Type' : 'multipart/form-data'},
		data: formData,
		// data:formData
	});
}
// 增加项目归档
export const addProjectResult = (params?: any) =>
	request({
		url: Api.AddProjectResult,
		method: 'post',
		data: params,
	});

// 删除项目归档
export const deleteProjectResult = (params?: any) =>
	request({
			url: Api.DeleteProjectResult,
			method: 'post',
			data: params,
		});
// 批量删除项目归档
export const batchDeleteProjectResult = (params?: any) =>
	request({
			url: Api.BatchDeleteProjectResult,
			method: 'post',
			data: params,
		});

// 编辑项目归档
export const updateProjectResult = (params?: any) =>
	request({
			url: Api.UpdateProjectResult,
			method: 'post',
			data: params,
		});

// 分页查询项目归档
export const pageProjectResult = (params?: any) =>
	request({
			url: Api.PageProjectResult,
			method: 'post',
			data: params,
		});
//下载项目归档模板
export const downLoadProjectResult = (params?: any) =>
	request({
			url: Api.DownLoadProjectResult,
			method: 'post',
			data: params,
			responseType: 'blob',
		});

